<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<title>${aier_title}</title>
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/multiselect.css" />
<link rel="stylesheet" href="${aier_css_url}jc/chosen.css">
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/reset.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/btn.css" />
<link rel="stylesheet" href="${aier_css_url}social/user/lookup.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/xxs.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}ui.js"></script>
<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/ja.js"></script>
<script type="text/javascript" src="${aier_js_url}jc/cj.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/multiselect.js"></script>

</head>
<body>
	-
	<!-- 顶栏 -->
	<s:action name="userhomecomm_homeHead" namespace="/user"
		executeResult="true"></s:action>

	<div class="window-content">

		<!-- wrap  -->

		<div class="wrap wrap-homepage wrap-tri-col hasgap clearfix">

			<s:action name="userhomecomm_homeLeft" namespace="/user"
				executeResult="true"></s:action>

			<!-- 主区域 (右  -->
			<div class="main-area clearfix">

				<!-- 中间栏 -->
				<div class="message-stream">
					<div class="stream-main">
						<div class="right-main-top">
							<div class="binfo-title" id="title">
								<h3>找人</h3>
							</div>
							<div class="right-line"></div>
						</div>

						<div class="searchCondition" id="condition">

							<div class="s_byaddres s_byaddres_class" style="padding-top:50px;">

								<!-- <div class="s-name-class">
									<label style="width:auto;">所在学校：</label>
								</div> -->
								<s:action name="citiesmap_cc" namespace="/common"
									executeResult="true"></s:action>
								<div class="s-school-class clearfix" style="margin-left:40px;">
									<div style="float:left;width:200px;"><label>学校<select style="width:150px" id = "schoolList"></select> </label></div>
									<div style="float:left;width:200px;"><label>班级<select style="width:150px" id = "classList"></select></label></div>
									
								</div>
							</div>
							
							<div class="s_byaddres s_byaddres_class" style="margin-top: 20px;">
								<div class="s-name-class">
									<label style="width:auto;">昵称： <input id="fsName" type="text"
										class="PY-input"></label>
								</div>

							</div> 
							
							<div class="s_byaddres s_byaddres_class" style="margin-top: 20px">
								<div class="s-name-class">
									<label>性别：</label> 
									<input type="radio" name="gender" checked="checked" value="-1">不限&nbsp;&nbsp;&nbsp;&nbsp;
									<input type="radio" name="gender" value="男">男&nbsp;&nbsp;&nbsp;&nbsp;
									<input type="radio" name="gender" value="女">女
								</div>

							</div>
							<div class="s_byaddres s_byaddres_class" style="margin-top: 20px">
								<a id="fsBtn" class="button btn-loc">搜索</a>
							</div>
						</div>

						<p class="result" style="" id="pResult">
							
						</p>


						<div class="resultList" id="resultList">

						</div>
					</div>
					<div id = "page"></div>
				</div>
				<!-- 右栏 -->
	            <s:action name="userhomecomm_homeRight" namespace="/user"
	                executeResult="true"></s:action>
			</div>
			<!-- 返回顶部 -->
			<s:action name="userhomecomm_backToTop" namespace="/user" executeResult="true"></s:action>
			<!-- end 返回顶部 -->
		</div>
		<!-- footer copyright -->
		<s:action name="userhomecomm_homeFooter" namespace="/user" executeResult="true"></s:action>
		<!-- /footer copyright -->
	</div>
</body>
<script type="text/javascript">
    var page = 1;       // 当前页
    var page_size = 10; // 每页的记录数
    
    $("#province").change(function() {
        searchSchoolByCid($("#province").val());
    });
    $("#city").change(function() {
        searchSchoolByCid($("#city").val());
    });
    $("#area").change(function() {
        searchSchoolByCid($("#area").val());
    });
    $("#street").change(function() {
        searchSchoolByCid($("#street").val());
    });
    $("#schoolList").change(function() {
        searchClassBySid($("#schoolList").val());
    });
    // 根据城市id查询学校列表
    function searchSchoolByCid(cid) {
    
        $("#schoolList").html("");
        $("#classList").html("");
        var fun=function(data){
            
            if(data.s==1){
                $("#schoolList").append("<option value='-1'>请选择</option>");
                if (data.schoolList != null && data.schoolList.length > 0) {
                    
                    for ( var i = 0; i < data.schoolList.length; i++) {
                        $("#schoolList").append(
                                "<option value='"+data.schoolList[i].sid+"'>" + data.schoolList[i].name + "</option>");
                    }
                }
            }
        };
        exeAjax(
             ajaxUrl("${aier_url}${aier_urijs}lookup_searchSchoolByCid${aier_suffix}"),
             fun,{
                 "scid":cid
        });
    }
    
    // 根据学校id查询班级列表
    function searchClassBySid(sid) {
        $("#classList").html("");
        var fun=function(data){
            
            if(data.s==1){
                $("#classList").append("<option value='-1'>请选择 </option>");
                if (data.classList != null && data.classList.length > 0) {
                    
                    for ( var i = 0; i < data.classList.length; i++) {
                        $("#classList").append(
                                "<option value='"+data.classList[i].cid+"'>" + data.classList[i].cname + "</option>");
                    }
                }
            }
        };
        exeAjax(
             ajaxUrl("${aier_url}${aier_urijs}lookup_searchAllClasses${aier_suffix}"),
             fun,{
                 "sid":sid
        });
    }
    
	//搜索
	$("#fsBtn").click(function() {
		searchPeople(page);
	});
	function searchPeople(nowpage) {
	    page = nowpage;
		// 学校id
        var sid = $("#schoolList").find("option:selected").val();
        // 班级id
        var cid = $("#classList").find("option:selected").val();
        // 昵称
		var nickname = $("#fsName").val();
		// 性别
		var sex = "-1";
		var gender = document.getElementsByName("gender");
           for(var i=0;i<gender.length;i++)
           {
               if(gender[i].checked)
                  sex = gender[i].value;
           }
		if (isnull(sid)) {
		    sid = -1;
		}
		if (isnull(cid)) {
		    cid = -1;
		}
		var fun = function(data) {

			if (data.s == 1) {
				appendPeople(data.userList);
                // 更新分页显示
                page = data.page;
                toLoadPage(page, page_size, data.page_count, data.count, "page", "searchPeople", null, null);
			    if (data.count == 0) {
                    $("#page").css("display","none");
                } else {
                    $("#page").css("display","block");
                }
			} else {
				$().message("搜索失败，请稍后再试！");
			}
		};
		exeAjax(
				ajaxUrl("${aier_url}${aier_urijs}lookup_searchPeopleByCondition${aier_suffix}"),
				fun, {
					"page" : page,
					"page_size" : page_size,
					"sid" : sid,
					"cid" : cid,
					"sex":sex,
					"nickname":nickname
				});

	}

	function appendPeople(userList) {
		var html = "";
		if (userList != null && userList.length > 0) {
			$("#pResult").html(
					'系统为您检索到 <span id="resultCount">' + userList.length
							+ '<b>+</b> </span> 个结果');

			for ( var i = 0; i < userList.length; i++) {
				var user = userList[i];
				html += '<div class="attent clearfix"><a href="${aier_url}user/uccomm_userCenter.shtml?in_type=1&in_uid='
						+ user.uid
						+ '"><img alt='+user.nickname+' width="40" height="40" src="${get_picturl_url}small/'+user.headimg+'"></a><div>';
				html += '<a href="${aier_url}user/uccomm_userCenter.shtml?in_type=1&in_uid='
						+ user.uid
						+ '"><font style="color:#c00000;">'
						+ user.nickname
						+ '</font></a><p>';
			    if (!isnull(user.desinfo)) {
			        html += user.desinfo;
			    }
			    html += '</p></div></div>';
			}
			

		} else {
			$("#pResult").html(
					'系统为您检索到 <span id="resultCount">0<b>+</b> </span> 个结果');
		}
		$("#resultList").html(html);
	}
</script>
</html>